#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int t,n,m,l,vm;
int ans;
struct node
{
    int d,v,a,s;
}car[100005];
struct nood
{
    int pos,fin;
}d[100005];
bool cmp(node a, node b)
{
    return a.s <  b.s;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t --)
    {
        scanf("%d%d%d%d",&n,&m,&l,&vm);
        for(int i = 1; i <= n; i ++)
        {
            cin >> car[i].d >> car[i].v >> car[i].a;
            if(car[i].a > 0) car[i].s =  1 + car[i].d + (pow(vm,2)-pow(car[i].v,2))/(car[i].a*2);
            else
            {
                if(car[i].v > vm) car[i].s = car[i].d;
                else car[i].s = l+8;
            }
        }
        for(int i = 1; i <= m; i ++) cin >> d[i].pos;
        sort(car+1, car+n+1, cmp);
        int j = 1,i = 1;
        while(i <= n)
        {
            while(car[i].s <= d[j].pos && i <= n)
            {
                d[j].fin = d[j-1].fin +1;
                i ++;
            }
            ans ++;
            if(i>n) d[m].fin = d[j].fin; break;
            j ++;
        }
        cout << d[j].fin+(m-ans-1) << " " << m-ans-1 << " \n";
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
